<template>
	<view class="">
		<view class="cu-bar bg-white solid-bottom  text-xl">
			<view class="action">
				<text class="cuIcon-titles text-blue"></text>
				我的收藏 ( {{dataList.length}} 道 )
			</view>
		</view>
		<view class="cu-list menu card-menu margin-top-sm " v-for="(item, index) in dataList"
			@click="gotoQuestionDetail(item)">
			<view class="cu-item arrow">
				<view class="content padding-tb-sm">
					<view class="text-cut cont_text_cut" style="width: 600upx">
						<text class="text-cut">
							{{index + 1}}. {{item.stem}}
						</text>
					</view>

					<view class="text-sm text-grey">
						{{item.categoryName}} - {{item.subjectName}} - {{item.chapterName}}
					</view>
					<view class="text-sm text-grey">
						{{item.createTime}}
						<view class="cu-tag margin-left round">
							<DictTag :options="choiceCategoryOptions" :value="item.choiceCategory" />
						</view>
					</view>
				</view>
			</view>
		</view>


		<view class="bg-white padding-xl" v-if="dataList.length == 0">
			<u-empty mode="data" text="暂无收藏记录"></u-empty>
		</view>
	</view>
</template>

<script>
	import {
		getDictData
	} from "@/api/api.js"
	import {
		qbmsQuestionFavoriteList
	} from "@/api/qbms.js"
	export default {
		data() {
			return {
				qbankId: 0, // 题库ID
				dataList: [], // 数据列表
				
				choiceCategoryOptions: [],
			}
		},
		onLoad() {
			this.qbankId = uni.getStorageSync("qbankId");
			this.initDict();
		},
		onShow() {
			
			this.getFavoriteList();
		},
		methods: {
			getFavoriteList() {
				qbmsQuestionFavoriteList({
					categoryId: this.qbankId
				}).then(res => {
					this.dataList = res.data;
				})
			},

			/** 跳转章节题目 */
			gotoQuestionDetail(item) {
				uni.$u.route({
					url: "/pages/qbms/questionDetail",
					params: {
						questionId: item.questionId,
						chapterName: item.chapterName,
						subjectName: item.subjectName,
					}
				})
			},
			/** 初始化字典 */
			initDict() {
				// 获取题库类型字典
				getDictData({
					dictType: "qbms_choice_category"
				}).then(res => {
					this.choiceCategoryOptions = res.data;
				})
			
			},
		}
	}
</script>

<style>

</style>
